Skip to content

Conversation

@lionel-rowe
Copy link
Contributor

@lionel-rowe lionel-rowe commented Sep 20, 2025

Fixes #6631

Default behavior remains unchanged. By setting the opt-in DIFF_CONTEXT_LENGTH env var (name subject to bikeshedding), you can enable output like this:

asciicast

Maybe this needs marked UNSTABLE (unstable version of internal/build-message with unstable versions of assert/equals and assert/strict-equals that are identical apart from doc + dependency change edit: probably better to just parameterize stable version and export a customized version from unstable)

@codecov
Copy link

codecov bot commented Sep 20, 2025

Codecov Report

❌ Patch coverage is 81.35593% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.12%. Comparing base (91d1d55) to head (7645e70).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
internal/truncate_build_message.ts 75.28% 21 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6835      +/-   ##
==========================================
- Coverage   94.16%   94.12%   -0.05%     
==========================================
  Files         573      575       +2     
  Lines       42400    42535     +135     
  Branches     6732     6767      +35     
==========================================
+ Hits        39928    40037     +109     
- Misses       2422     2446      +24     
- Partials       50       52       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lionel-rowe lionel-rowe force-pushed the truncate-big-diffs branch 4 times, most recently from de26b2d to f8d9a31 Compare September 20, 2025 17:33
@BlackAsLight
Copy link
Contributor

This looks pretty nice.

On a somewhat related topic I thought I made an issue suggesting directing the output to a file a while ago, but I can't seem to find it. The point being to allow one to parse the difference in an easier manner than in the terminal.

@lionel-rowe
Copy link
Contributor Author

lionel-rowe commented Sep 21, 2025

I thought I made an issue suggesting directing the output to a file

@BlackAsLight Is that necessary as part of the API though? Why not just pipe redirect stderr to a file?

$ NO_COLOR=1 deno eval "import { assertEquals } from 'jsr:@std/assert'; assertEquals(1, 2)" 2> errors.txt
$ cat errors.txt
error: Uncaught (in promise) AssertionError: Values are not equal.


    [Diff] Actual / Expected


-   1
+   2

  throw new AssertionError(message);
        ^
    at assertEquals (https://jsr.io/@std/assert/1.0.14/equals.ts:64:9)
    at file:///root/source/repos/$deno$eval.mts:1:49

@BlackAsLight
Copy link
Contributor

I thought I made an issue suggesting directing the output to a file

@BlackAsLight Is that necessary as part of the API though? Why not just pipe stderr to a file?

$ NO_COLOR=1 deno eval "import { assertEquals } from 'jsr:@std/assert'; assertEquals(1, 2)" 2> errors.txt

$ cat errors.txt

error: Uncaught (in promise) AssertionError: Values are not equal.





    [Diff] Actual / Expected





-   1

+   2



  throw new AssertionError(message);

        ^

    at assertEquals (https://jsr.io/@std/assert/1.0.14/equals.ts:64:9)

    at file:///root/source/repos/$deno$eval.mts:1:49

I didn't think of that, but that also seems pretty verbose and having it send its contents to a specific file only when it errors seems pretty convenient to me.

@kt3k kt3k changed the title feat(assert): truncate big diffs feat(assert/unstable): truncate big diffs Oct 6, 2025
@kt3k kt3k changed the title feat(assert/unstable): truncate big diffs feat(assert/unstable,internal): truncate big diffs Oct 6, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in review.

Looks reasonable improvement of diffs. LGTM

@kt3k kt3k merged commit 76d8c7c into denoland:main Oct 6, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assertEquals: better diffs for medium-large structured data with small differences

3 participants